﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using BOMS.Utility.DATA;

namespace BOMS.WebUI.Web.PowerControl
{
    public partial class PowerDownHistory : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            //  Repeater1.ItemDataBound +=new RepeaterItemEventHandler(Repeater1_ItemDataBound);
            if (!Page.IsPostBack)
            {             
                BindRepeater();                
            }
        }
      protected  void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item ||
                e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Model.PowerControl model = e.Item.DataItem as Model.PowerControl;
                if (model != null)
                {
                    Literal ltrDscTime = e.Item.FindControl("ltrDscTime") as Literal;
                    ltrDscTime.Text = Common.GetSpanTime(model.PowerOnTime.Value, model.PowerDownTime.Value);
                }
            }

        }
        void BindRepeater()
        {
            BLL.PowerControl bll = new BLL.PowerControl();
            List<Model.PowerControl> list = bll.GetModelList("BatGrpDscV=220 or IsPowerOn='否' or IsPowerOn='是'");
            Repeater1.DataSource = list;
            Repeater1.DataBind();
        }
    }
}